package com.jiji.miaosha.mapper;

import com.jiji.miaosha.entity.Sequence;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface SequenceMapper {

    @Select("select * from sequel_info where name=#{name} for update")
    Sequence getSequenceByName(@Param("name") String name);

    @Update("update sequel_info set current_value=#{sequence.currentValue},step=#{sequence.step} where name=#{sequence.name}")
    int updateSequence(@Param("sequence")Sequence sequence);
}
